import store from "@/store/index.js";
import config from './config.js';
import interfaces from './interfaces.js';
const tools = {
	get_playlet_numbers_string(playlet_numbers) {
		if (playlet_numbers.length <= 0) {
			return '[]'
		}
		let arr = '[';
		for (var i = 0; i < playlet_numbers.length; i++) {
			if (playlet_numbers[i] != null) {
				arr += i + ','
			}
		}
		return arr.substring(0, arr.length - 1) + ']'
	},
	sync_chasing(that, call_back) {
		let playlet_ids = uni.getStorageSync(config.zhuiju) || []
		let temp_list = []
		for (var i = 0; i < playlet_ids.length; i++) {
			if (playlet_ids[i] != null) {
				if (playlet_ids[i] === true) {
					temp_list.push(i)
				}
			}

		}
		let self = that;
		console.log("temp_list", JSON.stringify(temp_list))
		self.request({
			url: interfaces.sync_chasing,
			hideLoading: true,
			data: {
				"playlet_ids": JSON.stringify(temp_list)
			},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(res)
				}
			}
		});
	},
	sync_zl_list(that, json, call_back) {
		let self = that;
		self.request({
			url: interfaces.sync_zl_list,
			hideLoading: true,
			data: {
				"sync_data": json
			},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(res)
				}
			}
		});
	},
	like_video(that, playlet_id, playlet_number, stype, call_back) {
		let self = that;
		self.request({
			url: interfaces.likes,
			hideLoading: true,
			data: {
				playlet_id,
				playlet_number,
				stype
			},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(true);
				} else {
					call_back(false);
				}
			}
		});
	},
	sync_likes(that, playlet_id, call_back) {
		let self = that;
		let _like = uni.getStorageSync(config.like) || []
		let playlet_numbers = _like[playlet_id] || []
		let numbers = this.get_playlet_numbers_string(playlet_numbers)
		self.request({
			url: interfaces.sync_likes,
			hideLoading: true,
			data: {
				"playlet_id": playlet_id,
				"playlet_numbers": numbers
			},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(res)
				}
			}
		});
	},
	getRecommendListStatus(that, call_back) {
		let self = that;
		self.request({
			url: interfaces.zl_list,
			data: {},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(res)
				}
			}
		});
	},
	getVideoListStatus(that, playlet_id, call_back) {
		let self = that;
		self.request({
			url: interfaces.likes_list,
			data: {
				"playlet_id": playlet_id
			},
			method: config.post,
			success: (res) => {
				call_back(res);
			},
			catch: (err) => {
				call_back(err)
				console.log(err);
			},
		});
	},
	buy_episodes_list(that, playlet_id, call_back) {
		let self = that;
		self.request({
			url: interfaces.buy_episodes_list,
			data: {
				"playlet_id": playlet_id
			},
			method: config.post,
			success: (res) => {
				if (res.code === config.SUCCESS) {
					call_back(res)
				}
			}
		});
	},
	isVip(that, call_back) {
		let user = this.get_user_info();
		if (user.is_vip === config.VIP) {
			let vip_effective_time_time = user.vip_effective_time_time;
			that.request({
				url: interfaces.sys_time,
				method: config.get,
				success: (res) => {
					if (res.code === config.SUCCESS) {
						call_back(vip_effective_time_time >= res.content.sys_time)
					}else{
						call_back(false);
					}
				},
				catch:(err)=>{
					call_back(false);
				}
			})
		} else {
			call_back(false)
		}
	},
	consume_playlet(that, playlet_id, playlet_number, call_back) {
		let self = that;
		self.request({
			url: interfaces.buyr,
			data: {
				"playlet_id": playlet_id,
				"playlet_number": playlet_number
			},
			method: config.post,
			success: (res) => {
				call_back(res);
			}
		});
	},
	is_can_consume(consume) {
		let {
			ml_coin,
			give_coin
		} = this.get_user_info();
		let coin = (ml_coin || 0) + (give_coin || 0);
		console.warn('===判断用户的看币够不够解锁===');
		console.warn('自己的币：'+coin);
		console.warn('解锁剧需要的币：'+consume);
		if (coin >= consume) {
			console.warn('==够币==去自动解锁');
			return true;
		}
		console.warn('==币不足==应该弹充值');
		uni.showToast({title: "币不足！请充值",duration: 1000,icon: "none"})
		return false;
	},
	update_history(object = {}) {
	
		let _history = uni.getStorageSync(config.history) || [];
		if (Array.isArray(_history)) {
		
				

				// if(!_history.some(i=>i.playlet_id == object.playlet_id)){
				// 	_history.push(object)
				// }else{
				// 	_history = _history.filter(item => item.playlet_id != object.playlet_id )
				// 	_history.unshift(object)
				// }
				// uni.setStorageSync(config.history, _history)
				
				
				
				
				// console.log(999,_history)
				// if(!_history.some(i=> (i.playlet_id == object.playlet_id) && (i.playlet_number == object.playlet_number) )){
				// 	console.log(218)
				// 	_history.unshift(object)
				// }else{
				// 	console.log(222)
				// 	_history = _history.filter(item => (item.playlet_id != object.playlet_id && item.playlet_number != object.playlet_number)  )
				// 	_history.unshift(object)
				// }
				
				
		
				// uni.setStorageSync(config.history, _history)
				
				// console.log(231,uni.getStorageSync(config.history))
			let found = false;
			// 遍历数组中的每个元素
			for (let i = 0; i < _history.length; i++) {
				let item = _history[i];
				// 判断 playlet_id 是否一致
				if (item.playlet_id == object.playlet_id) {
					found = true;
					// 如果一致，再判断 playlet_number 是否一致
					if (item.playlet_number == object.playlet_number) {
						// 删除,再塞到数组最前面
						_history.splice(i,1);
						_history.unshift(item);
						uni.setStorageSync(config.history, _history);
						break;
					}else{
						found = false;
					}
				}
			}
			// 如果数组为空或者 playlet_id 不一致，则将对象推入数组
			if (_history.length === 0 || !found) {
				_history.unshift(object);
				console.warn('观看历史111');
				console.log(_history);
				uni.setStorageSync(config.history, _history);
			}
		}
	},
	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  let id = 0; // 注意id 是推荐列表的顺序id,不是短剧id
	 *  tools.jump_video_recommend(id)
	 * 
	 */
	jump_video_recommend(id) {
		uni.switchTab({
			url: '/pages/tabBar/recommend/recommend?id=' + id,
			success: (r) => {
				getApp().globalData.start_id = id;
				console.log("jump_video_recommend success");
			}
		});
	},
	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  tools.jump_video_page_by_info({playlet_id:0,name:"",last_episode_number:100})
	 * 
	 */
	jump_video_page_by_info(info) {
		console.warn('=====跳转视频播放页=====');
		if (!info.playlet_id) {
			uni.showModal({
				title: '没有传入id',
				showCancel: false,
			})
			return
		}

		// if (!info.name) {
		// 	uni.showModal({
		// 		title: '没有传入名字',
		// 		showCancel: false,
		// 	})
		// 	return
		// }

		// if (!info.playlet_number) {
		// 	info.playlet_number = 1
		// 	console.log("没有传入集数")
		// }

		// if (!info.last_episode_number) {
		// 	console.log("没有传入最后一集")
		// }
		// uni.navigateTo({
		// 	url: '/pages/videopage/videopage?spread_id=15&pid=23&peid=4'
		// })
		uni.navigateTo({
			url: '/pages/videopage/videopage?video_info=' + encodeURIComponent(JSON.stringify(info))
		})
	},
	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  let history_last_item =  tools.get_history_last_item()
	 *	if(history_last_item!=null){
	 *		
	 *	}
	 * 
	 */
	get_history_last_item() {
		let list = this.get_history() || [];
		console.log(list);
		if (list.length) {
			if (typeof list[0] == 'object' && list[0] != null) {
				return list[0];
			} else {
				return {};
			}
		} else {
			return {};
		}
	},
	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  let history_sort_time =  tools.get_history_sort_time()
	 *	if(history_sort_time!=null){
	 *		
	 *	}
	 * 
	 */
	get_history_sort_time() {
		let list = this.get_history() || []
		let temp_list = [];
		for (var i = 0; i < list.length; i++) {
			if (list[i] != null && list[i] != undefined) {
				temp_list.push(list[i])
			}

		}
		if (temp_list.length <= 0) {
			return null
		}
		temp_list.sort(function(a, b) {
			return b.time - a.time
		})
		return temp_list
	},
	get_history() {
		let _history = uni.getStorageSync(config.history) || [];
		console.warn('=============获取历史==========');
		console.log(_history);
		return _history;
	},



	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  
	 *  tools.update_user_info(data)
	 * 
	 */
	update_user_info(data) {
		console.warn('===拿到用户信息了，更新用户信息===');
		console.log(data);
		store.commit("mut_userInfo", data);
	},

	/**
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  
	 *  tools.get_user_info()
	 * 
	 */
	get_user_info() {
		if (typeof store.state.user.userInfo == 'object') {
			if (JSON.stringify(store.state.user.userInfo) != '{}') {
				return store.state.user.userInfo;
			}
		}
		return uni.getStorageSync('userInfo') || {};
	},
	isNull(obj) {
		if (obj != null && obj != undefined && obj != '' && obj.length != 0) {
			return false;
		}
		return true;
	},
	
	get_user_info_by_serve(that,call_back) {
		
		let spread_id = uni.getStorageSync(config.spread_id)
		that.request({
			url: interfaces.info,
			data: {
				"spread_id": spread_id
			},
			method: config.post,
			success: (res) => {
				console.warn("===获取用户信息===");
				store.commit("mut_userInfo", res.content);
				console.log(res.content);
				call_back(res.content);
			}
		});
	},
	
	/**
	 *  导航到福利中心
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  tools.navigateToWelfare()
	 */
	navigateToWelfare() {
		uni.navigateTo({
			url: '/pages/welfare/welfare'
		})
	},
	/**
	 *  设置订阅消息
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  tools.setup_subscribeMessage()
	 */
	setup_subscribeMessage() {
		uni.getSetting({
			withSubscriptions: true,
			success(res) {
				if (!res.subscriptionsSetting.mainSwitch) {
					uni.showModal({
						title: '温馨提示',
						content: '您还没有开启订阅消息的权限,是否去设置',
						success: function(resdata) {
							if (resdata.cancel) {
								uni.showToast({
									title: '拒绝',
									icon: 'none',
									duration: 1000
								})
							} else if (resdata.confirm) {
								uni.openSetting({
									withSubscriptions: true,
									success: function(dataAu) {
										console.log('打开设置了', dataAu)
									}
								})
							}
						}
					})
				} else {
					uni.requestSubscribeMessage({
						tmplIds: ['AoV7ffMOwgXb7noTuo3xgXR9M6wWEzbV-Qm5Y9yBCqc',
							'pDgOdQWNEOWPx_QePUYRjEze1BIvvGF4p7tf4hCAhHs',
							'nCrKbyOXfhSL30CMPrcPzHWSWqjyB6RaA5tC7cjrp8Q'
						],
						success(resres) {
							console.log('成功成功', resres)
							var subscribe1 = false
							var subscribe2 = false
							var subscribe3 = false
							if (resres['AoV7ffMOwgXb7noTuo3xgXR9M6wWEzbV-Qm5Y9yBCqc'] == 'accept') {
								subscribe1 = true
							} else if (resres['pDgOdQWNEOWPx_QePUYRjEze1BIvvGF4p7tf4hCAhHs'] ==
								'accept') {
								subscribe2 = true
							} else if (resres['nCrKbyOXfhSL30CMPrcPzHWSWqjyB6RaA5tC7cjrp8Q'] ==
								'accept') {
								subscribe3 = true
							}
							// 如果都选择不提醒,确定按钮是不能点击的. 否则就是用户点击了取消按钮
							if (subscribe1 == true || subscribe2 == true || subscribe3 == true) {
								tools.pushTodayDingyue()
								uni.showToast({
									title: '更新将会提醒您',
									duration: 1500
								})
							}
							// if(res['id'] == 'reject') {
							// 	uni.showModal({
							// 	    title: '舒适提示',
							// 	    content: "您已关闭消息推送，如须要消息推送服务，请点击确定跳转设置页面打开受权后再次尝试。",
							// 	    success: function(modal) {
							// 	        if (modal.confirm) { // 点击确定
							// 			    uni.openSetting({withSubscriptions:true})
							// 	        }
							// 	    }
							// 	})
							// }
						},
						fail(fail) {
							// console.log('失败失败', fail)
							// if(fali.errCode == '20004') {
							// 	uni.showModal({
							// 	    title: '舒适提示',
							// 	    content: "您已关闭消息推送，如须要消息推送服务，请点击确定跳转设置页面打开受权后再次尝试。",
							// 	    success: function(modal) {
							// 	        if (modal.confirm) { // 点击确定
							// 			    uni.openSetting({withSubscriptions:true})
							// 	        }
							// 	    }
							// 	})
							// }
							uni.showToast({
								icon: 'error',
								title: '更新提醒失败',
								duration: 1000
							})
						}
					})
				}
			}
		})
	},
	/**
	 *  保存图片
	 */
	saveImageToAlbum(imageUrl) {
		uni.authorize({
			scope: 'scope.writePhotosAlbum',
			success() {
				uni.showLoading({
					title: '保存中'
				})
				uni.downloadFile({
					url: imageUrl,
					success: (res) => {
						uni.hideLoading()
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										icon: 'none',
										title: '保存成功'
									})
								},
								fail: function() {
									uni.showToast({
										icon: 'none',
										title: '保存失败,请稍后重试'
									})
								}
							})
						} else {
							uni.showToast({
								icon: 'error',
								title: '保存失败了'
							})
						}
					},
					fail: (err) => {
						uni.showToast({
							icon: 'none',
							title: err.errMsg
						})
					}
				})
			},
			fail: () => {
				uni.getSetting({
					success: (result) => {
						if (!result.authSetting['scope.writePhotosAlbum']) {
							uni.showModal({
								content: '由于您还没有允许保存图片到您相册里,无法进行保存,请点击确定允许授权',
								success: (res) => {
									if (res.confirm) {
										uni.openSetting({
											success: (result) => {
												console.log(result
													.authSetting
												)
											}
										})
									}
								}
							})
						}
					}
				})
			}
		})
	},
	ms_time(s) {
		if (!s || s === null || s === '' || s === undefined) {
			return "00:00"
		}
		s = parseInt(s)
		var n_s = Math.floor(s / 60)
		if (n_s < 0) {
			n_s = 0;
		}
		var n_s_str = n_s.toString()
		var n_m = s % 60
		if (n_m < 0) {
			n_m = 0;
		}
		var n_m_str = n_m.toString()
		if (n_s < 10 && n_s >= 0) {
			n_s_str = "0" + n_s
		}
		if (n_m < 10 && n_m >= 0) {
			n_m_str = "0" + n_m
		}
		return n_s_str + ":" + n_m_str
	},
	intToChinese(num) {
		if (!/^\d*(\.\d*)?$/.test(num)) {
			// alert("Number is wrong!");
			return "Number is wrong!";
		}
		let AA = new Array("零", "一", "二", "三", "四", "五", "六", "七", "八", "九");
		let BB = new Array("", "十", "百", "千", "万", "亿", "点", "");
		let a = ("" + num).replace(/(^0*)/g, "").split("."),
			k = 0,
			re = "";
		if (num === 15) {
			// console.log("intToChinese",a,a[0].length,a[0].charAt(0))
		}

		for (let i = a[0].length - 1; i >= 0; i--) {
			switch (k) {
				case 0:
					re = BB[7] + re;
					break;
				case 4:
					if (!new RegExp("0{4}\\d{" + (a[0].length - i - 1) + "}$").test(a[0]))
						re = BB[4] + re;
					break;
				case 8:
					re = BB[5] + re;
					BB[7] = BB[5];
					k = 0;
					break;
			}
			if (k % 4 == 2 && a[0].charAt(i + 2) != 0 && a[0].charAt(i + 1) == 0) re = AA[0] + re;
			if (a[0].charAt(i) != 0) {
				if (a[0].charAt(0) === "1" && a[0].length === 2) {
					if (i === 0) {
						re = BB[k % 4] + re;
					} else {
						re = re + AA[a[0].charAt(1)];
					}

				} else {
					re = AA[a[0].charAt(i)] + BB[k % 4] + re;
				}

			}
			k++;
		}
		if (a.length > 1) { //加上小数部分(如果有小数部分) 
			re += BB[6];
			for (let i = 0; i < a[1].length; i++) re += AA[a[1].charAt(i)];
		}
		return re;
	},

	isToday(date_time) {
		let today = new Date();
		let date = new Date(date_time);
		console.log("toLocaleTimeString==", date.toLocaleTimeString())
		if (today.getFullYear() === date.getFullYear() && today.getMonth() === date.getMonth() && today
			.getDate() === date.getDate()) {
			return true;
		}
		return false;
	},
	update_zhuiju(playlet_id, iszhuiju, info, isinit = false) {
		let _zhuiju = uni.getStorageSync(config.zhuiju) || []
		if (!_zhuiju[playlet_id]) {
			_zhuiju[playlet_id] = false
		}
		if (isinit) {
			let local_iszhuiju = this.get_zhuiju(playlet_id)
			if (local_iszhuiju === false) {
				iszhuiju = false
			}
		}
		_zhuiju[playlet_id] = iszhuiju;
		if (iszhuiju && !isinit) { //set今天追剧
			this.pushTodayZhuiJu(playlet_id)
		}
		if (info != null && info != undefined) {
			let new_obj = {
				playlet_id: info.playlet_id,
				name: info.name,
				cover: info.cover,
				last_episode_number: info.last_episode_number
			}
			if (iszhuiju) {
				this.chaseListPushData(new_obj)
			} else {
				this.chaseListDeleteData(new_obj)
			}
		}
		uni.setStorageSync(config.zhuiju, _zhuiju)
	},
	get_zhuiju(playlet_id) {
		let _zhuiju = uni.getStorageSync(config.zhuiju) || []
		if (_zhuiju.length > 0) {
			if (_zhuiju[playlet_id] != null) {
				return _zhuiju[playlet_id]
			}
		}
		return null;
	},
	update_like(playlet_id, playlet_number, islike) {
		let _like = uni.getStorageSync(config.like) || []
		if (!_like[playlet_id]) {
			_like[playlet_id] = []
		}
		_like[playlet_id][playlet_number] = islike;
		if (islike) {
			this.pushTodayLike(playlet_id, playlet_number)
		}
		uni.setStorageSync(config.like, _like)
	},
	get_like(playlet_id, playlet_number) {
		let _like = uni.getStorageSync(config.like) || []
		if (_like.length > 0) {
			if (_like[playlet_id] != null) {
				if (_like[playlet_id][playlet_number] != null) {
					return _like[playlet_id][playlet_number]
				}
			}
		}
		return null;
	},
	pushTodayLike(playlet_id, playlet_number) {
		let _today_like = uni.getStorageSync(config.today_like) || []
		let _date_string = new Date().valueOf()
		_today_like[(playlet_id * playlet_number) + playlet_id] = {
			"_date_string": _date_string,
			"playlet_id": playlet_id,
			"playlet_number": playlet_number
		}
		uni.setStorageSync(config.today_like, _today_like)
	},
	/**
	 *  获取今天点赞列表
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  let list = tools.getTodayLike()
	 */
	getTodayLike() {
		let _today_like = uni.getStorageSync(config.today_like) || []
		let _date_string = new Date().valueOf()
		let temp_list = []
		for (var i = 0; i < _today_like.length; i++) {
			if (_today_like[i] != null) {
				if (this.isToday(_today_like[i]._date_string)) {
					temp_list.push(_today_like[i])
				}
			}
		}
		uni.setStorageSync(config.today_like, temp_list)
		return temp_list
	},
	pushTodayZhuiJu(playlet_id) {
		let _today_zhuiju = uni.getStorageSync(config.today_zhuiju) || []
		let _date_string = new Date().valueOf()
		_today_zhuiju[playlet_id] = {
			"_date_string": _date_string,
			"playlet_id": playlet_id
		}
		uni.setStorageSync(config.today_zhuiju, _today_zhuiju)
	},
	/**
	 *  获取今天追剧列表
	 *  示例
	 * 	import tools from "@/utils/tools.js";
	 *  let list = tools.getTodayZhuiJu()
	 */
	getTodayZhuiJu() {
		let _today_zhuiju = uni.getStorageSync(config.today_zhuiju) || []
		let _date_string = new Date().valueOf()
		let temp_list = []
		for (var i = 0; i < _today_zhuiju.length; i++) {
			if (_today_zhuiju[i] != null) {
				if (this.isToday(_today_zhuiju[i]._date_string)) {
					temp_list.push(_today_zhuiju[i])
				}
			}
		}
		uni.setStorageSync(config.today_zhuiju, temp_list)
		return temp_list
	},
	pushTodayDingyue() {
		let _today_dingyue = uni.getStorageSync(config.today_dingyue) || {}
		let date = _today_dingyue["date"]
		let count = _today_dingyue["count"]
		let _date_string = new Date().valueOf()
		let tempData = {}
		if (this.isToday(date)) {
			tempData = {
				"date": _date_string,
				"count": count + 1
			}
		} else {
			tempData = {
				"date": _date_string,
				"count": 1
			}
		}
		console.log("tempData:", tempData)
		uni.setStorageSync(config.today_dingyue, tempData)
	},
	/**
	 * 获取今天订阅消息数量
	 * 示例
	 * import tools from "@/utils/tools.js";
	 * let dingyueCount = tools.getTodayDingyue()
	 */
	getTodayDingyue() {
		let _today_dingyue = uni.getStorageSync(config.today_dingyue) || {}
		let date = _today_dingyue["date"]
		let count = _today_dingyue["count"]
		if (this.isToday(date)) {
			return count
		} else {
			return 0
		}
	},
	/**
	 * 追剧列表更新
	 */
	chaseListUpdate(dataList) {
		uni.setStorageSync(config.chaseList, dataList)
	},
	/**
	 * 追剧列表获取从缓存
	 */
	chaseListGetForCache() {
		return uni.getStorageSync(config.chaseList) || []
	},
	/**
	 * 追剧列表添加数据
	 * 示例 
	 * import tools from "@/utils/tools.js";
	 * tools.chaseListPushData({playlet_id:0,name:"",cover:"",last_episode_number:100})
	 */
	chaseListPushData(info) {
		if (!info.playlet_id) {
			uni.showModal({
				title: '没有传入id',
				showCancel: false,
			})
			return
		}
		if (!info.name) {
			uni.showModal({
				title: '没有传入名字',
				showCancel: false,
			})
			return
		}
		if (!info.cover) {
			uni.showModal({
				title: '没有传入图片',
				showCancel: false,
			})
			return
		}
		if (!info.last_episode_number) {
			uni.showModal({
				title: '没有传入最后一集',
				showCancel: false,
			})
			return
		}

		// console.log("添加:", info)
		var dataList = this.chaseListGetForCache()
		var isHav = false
		for (var i = 0; i < dataList.length; i++) {
			if (dataList[i].playlet_id === info.playlet_id) {
				isHav = true
				break;
			}
		}
		if (isHav === false) {
			let count = 50
			if (dataList.length >= count) {
				dataList.splice(count - 1, 1)
			}
			let data = {
				playlet_id: info.playlet_id,
				cover: info.cover,
				playlet_name: info.name,
				last_episode_number: info.last_episode_number
			}
			dataList.unshift(data)
			tools.chaseListUpdate(dataList)
			uni.$emit(config.notification_chaseList_add, dataList)
		}
	},
	/**
	 * 追剧列表删除数据
	 * 示例 
	 * import tools from "@/utils/tools.js";
	 * tools.chaseListDeleteData({playlet_id:0})
	 */
	chaseListDeleteData(info) {
		if (!info.playlet_id) {
			uni.showModal({
				title: '没有传入id',
				showCancel: false,
			})
			return
		}
		// console.log("删除:", info)
		var dataList = this.chaseListGetForCache()
		for (var i = 0; i < dataList.length; i++) {
			if (dataList[i].playlet_id === info.playlet_id) {
				dataList.splice(i, 1)
				tools.chaseListUpdate(dataList)
				uni.$emit(config.notification_chaseList_delete, dataList)
				break;
			}
		}
	},
	/**
	 * 追剧列表排序
	 * 示例 
	 * import tools from "@/utils/tools.js";
	 * tools.chaseListSort(chaseList, data, index)
	 * chaseList:我的追剧-列表数据
	 */
	chaseListSort(chaseList, data, index) {
		let currentData = chaseList[index]
		if (currentData.playlet_id === data.playlet_id) {
			if (index != 0) {
				chaseList.splice(index, 1)
				chaseList.unshift(data)
				tools.chaseListUpdate(chaseList)
			}
		}
	}
}
module.exports = tools;